package tp.badugi.bot;

import static org.junit.Assert.*;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import tp.badugi.net.GameStatus;
import tp.badugi.net.iRequestListener;

public class BettingTest {

	private BotCalculatedBettingStrategy botCalculatedBetting;
	
	@Before
	public void before() throws Exception {
		this.botCalculatedBetting = new BotCalculatedBettingStrategy();
	}
	
	@After
	public void after() throws Exception {
	}
	
	@Test
	public void Best_Cards_Round_3_Starting_Money_3000_Used_1500_Actions_CH_B_A_F_Expected_Bet_750(){
		GameStatus givenStatus = new GameStatus();
		String[] givenActions = new String[]{	iRequestListener.ACTION_CHECK,
												iRequestListener.ACTION_BET,
												iRequestListener.ACTION_ALLIN,
												iRequestListener.ACTION_FOLD};
		
		givenStatus.betAmount = 0;
		givenStatus.bettingRound = 3;
		givenStatus.myCards = new String[]{"AC","2D","3H","4S"};
		givenStatus.myChipCount = 1500;
		givenStatus.myPlayerNumber = 0;
		givenStatus.potSize = 4000;
		givenStatus.numberOfPlayers = 3;
		givenStatus.playerPotContributions = new long[]{1500,1500,1000};
		
		String expectedAction = iRequestListener.ACTION_BET;
		long expectedMinBet = 637;
		long expectedMaxBet = 863;
		
		this.botCalculatedBetting.makeAction(givenStatus, givenActions);
		
		String botAction = this.botCalculatedBetting.chosenAction;
		long botBet = this.botCalculatedBetting.betAmount;
		
		assertTrue(botBet >= expectedMinBet && botBet <= expectedMaxBet);
		assertEquals(expectedAction, botAction);
		
	}
	
	@Test
	public void Card_Value_7523_Round_2_Starting_Money_3000_Used_500_Actions_CA_R_A_F_Current_Bet_150_Expected_Call_150(){
		GameStatus givenStatus = new GameStatus();
		String[] givenActions = new String[]{	iRequestListener.ACTION_CALL,
												iRequestListener.ACTION_RAISE,
												iRequestListener.ACTION_ALLIN,
												iRequestListener.ACTION_FOLD};
		
		givenStatus.betAmount = 150;
		givenStatus.bettingRound = 2;
		givenStatus.myCards = new String[]{"7C","9D","QH","JS"};
		givenStatus.myChipCount = 2500;
		givenStatus.myPlayerNumber = 0;
		givenStatus.potSize = 1300;
		givenStatus.numberOfPlayers = 3;
		givenStatus.playerPotContributions = new long[]{500,650,150};
		
		String expectedAction = iRequestListener.ACTION_CALL;
		long expectedBet = 0;
		
		this.botCalculatedBetting.makeAction(givenStatus, givenActions);
		
		String botAction = this.botCalculatedBetting.chosenAction;
		long botBet = this.botCalculatedBetting.betAmount;
		
		assertEquals(expectedBet, botBet);
		assertEquals(expectedAction, botAction);
		
	}

}
